const express = require("express");
// const cookieParser = require("cookie-parser");
// const session = require("express-session");
const multer = require("multer");

// 路由模块
const loginRoute = require("./router/login");
const registerRoute = require("./router/register");
const setPasswordRoute = require("./router/setPassword");
const productsRoute=require('./router/products')
const userinfoRoute=require('./router/userinfo')
const getgoodsRoute=require('./router/getgoods.js');
const getuserRoute=require('./router/getuser.js');
const getuserproRoute=require('./router/getuserpro');
const setpictureRoute=require('./router/setpicture');

const app = express();
const upload = multer({dest:"./upload"});

app.use( express.urlencoded());
app.use( express.static("./www") );
app.use( express.static("./upload") );
app.use( upload.any() );
//10.11.55.72:3000
//登录   username(str)  password(str)
app.post("/login", loginRoute);
//注册  username(str)  password(str)  tel(str)
app.post("/register", registerRoute);
//修改密码    token, uId, opassword, npassword
app.post("/setpassword", setPasswordRoute);
//商品上架       token, gname, gdetails, gsport, gmoney, gtime 必填
app.post("/products",productsRoute);
//修改用户信息      token, age, sex, tel, nickName 必填
app.post('/userinfo',userinfoRoute);
//获取商品信息      token 必填
app.post('/getgoods',getgoodsRoute);
//获取当前登录用户的已上架商品信息  token 
app.post('/getuserpro',getuserproRoute);
//获取当前登录的用户信息    token
app.post('/getuser',getuserRoute);
//修改头像  token  filename  
app.post('/setpicture',setpictureRoute);
//导出用户信息
//引入用户信息
//导出商品信息
//引入商品信息
app.listen(3000);